package net.zjitc.servlet;

import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by Administrator on 2017/9/25.
 */
public class GServlet extends GenericServlet {
    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {

        //如何获得servletConfig,已经有方法了，可以直接用
        ServletConfig config = this.getServletConfig();
        String value = config.getInitParameter("gKey");
        PrintWriter out = servletResponse.getWriter();
        out.write("gServlet value = ");
        out.write(value);
        out.write("<br/>");
        //Context
        ServletContext context = this.getServletContext();

        String path = context.getRealPath("/");

        out.write(path);

        out.write("这是我的测试页面");
        //if(servletRequest.getmethd()get)
    }
}
